<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta content="" name="keywords">

  <title> 杂技浅尝 - </title>
  <meta name="description" content="" />
  <meta property="og:title" content="杂技浅尝" />
  <meta name="twitter:title" content="杂技浅尝" />
  <meta name="author" content="{Description { .Site.Author.name }}"/>
  <meta name="twitter:card" content="summary" />
  <meta property="og:url" content="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/" />
  <meta property="og:type" content="website" />
  <meta property="og:site_name" content="听风的小站" />

  <meta name="generator" content="Hugo 0.67.0" />
  <link rel="canonical" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/" />
  <link rel="alternate" href="https://systemime.github.io/index.xml" type="application/rss+xml" title="听风的小站">
  <script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/jquery-1.12.4.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  
  
  <link rel="stylesheet" href="https://systemime.github.io/css/main.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/my.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pace.css" />
  <link rel="stylesheet" href="https://cdn.plyr.io/3.4.7/plyr.css">
  <link rel="stylesheet" href="https://systemime.github.io/css/lightgallery.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/baguetteBox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/search.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/reward.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/share.min.css" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pygment_highlights.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/highlight.min.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/toc.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/lightbox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/live2d/css/live2d.css" />
  
  <link href="https://systemime.github.io/css/video-js.css" rel="stylesheet">


<meta name="baidu-site-verification" content="g8IYR9SNLF" />
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cffe439e37449bb1c07ab26ab56484bb";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<link rel="stylesheet" href="https://systemime.github.io/css/prism.css" />









<script src="https://systemime.github.io/js/pace.min.js" data-no-instant></script>



<script src="https://systemime.github.io/js/instantclick.min.js" data-no-instant></script>
   <script data-no-instant>
   InstantClick.on('change', function(isInitialLoad) {
     if (isInitialLoad === false) {
       if (typeof MathJax !== 'undefined') 
         MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
       if (typeof prettyPrint !== 'undefined') 
         prettyPrint();
       if (typeof _hmt !== 'undefined')  
         _hmt.push(['_trackPageview', location.pathname + location.search]);
       if (typeof ga !== 'undefined')  
           ga('send', 'pageview', location.pathname + location.search);
     }
   });
   InstantClick.init();
</script>




<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.7.1/gist-embed.min.js"></script>


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-3925981084585036",
    enable_page_level_ads: true
  });
</script>



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe.min.css" integrity="sha256-sCl5PUOGMLfFYctzDW3MtRib0ctyUvI9Qsmq2wXOeBY=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/default-skin/default-skin.min.css" integrity="sha256-BFeI1V+Vh1Rk37wswuOYn5lsTcaU96hGaI7OUVCLjPc=" crossorigin="anonymous" />



<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

<div class="pswp__bg"></div>

<div class="pswp__scroll-wrap">
    
    <div class="pswp__container">
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
    </div>
    
    <div class="pswp__ui pswp__ui--hidden">
    <div class="pswp__top-bar">
      
      <div class="pswp__counter"></div>
      <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
      <button class="pswp__button pswp__button--share" title="Share"></button>
      <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
      <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
      
      
      <div class="pswp__preloader">
        <div class="pswp__preloader__icn">
          <div class="pswp__preloader__cut">
            <div class="pswp__preloader__donut"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
      <div class="pswp__share-tooltip"></div>
    </div>
    <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
    </button>
    <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
    </button>
    <div class="pswp__caption">
      <div class="pswp__caption__center"></div>
    </div>
    </div>
    </div>
</div>

</head>

  <body>
    <nav class="navbar navbar-default navbar-fixed-top navbar-custom">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="https://systemime.github.io">听风的小站</a>
    </div>
    <div class="collapse navbar-collapse" id="main-navbar">
      <ul class="nav navbar-nav navbar-right">
        
          
            <li>
		    <a title="博客" href="https://systemime.github.io/blog/">博客</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="片刻" href="https://systemime.github.io/moment/">片刻</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="关于" href="https://systemime.github.io/about/">关于</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="留言" href="https://systemime.github.io/message/">留言</a>
              
              
            </li>
          
        

        

        
        
      </ul>
    </div>

    <div class="avatar-container">
      <div class="avatar-img-border">
        
      </div>
    </div>

  </div>
</nav>






    
  <header class="header-section ">
    <div class="intro-header no-img">
      <div class="container">
        <div class="row">
          <div class="col-lg-12 col-md-12 col-md-offset-0">
            <div class="page-heading">
              <h1>#杂技浅尝</h1>
              <hr class="small">
            </div>
          </div>
        </div>
      </div>
    </div>
  </header>

    
  <div class="container" role="main">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        
        <div class="posts-list">
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-02/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%93%8D%E4%BD%9C%E5%AE%9E%E8%B7%B5/">
                <h2 class="post-title">正则表达式操作实践</h2>

                
              </a>

              <p class="post-meta">
                Posted on February 25, 2019
              </p>
              <div class="post-entry">
                
                  <h1 id="正则表达式操作实践">正则表达式操作实践</h1>
<p>来自 <a href="https://python123.io/">Python123</a>
有一些网站提供了常用的正则表达式和测试环境，例如</p>
<ul>
<li><a href="https://regexr.com/">regexr.com</a> 一个非常棒的在线环境，我经常使用</li>
<li><a href="http://regexlib.com/">regexlib.com</a> 一个非常棒的在线环境，我经常使用</li>
</ul>
<h3 id="高效文本处理---1">高效文本处理 - 1</h3>
<p>原始文本如下</p>
<pre><code> 张伟        17664999502  \n
 王伟       17187690316   \n
  王芳        14210007607   \n
 李伟         15878807133  \n
  王秀英    15575237523    \n
 李秀英  15695435545    \n
  李娜       18346347153   \n
  张秀英    17017338288   \n
   刘伟  15481361668  \n
  张敏        13528947724    \n
    李静         18522824481 \n
  张丽   14352788577     \n
  王静      18637851730    \n
 王丽        15862244782  \n
 李强   14363718204   \n
 张静  13418111578     \n
    李敏         15657258884  \n
    王敏         17574922377 \n
 王磊        14517362847 \n
  李军         18088271014  \n
 刘洋     17897166967     \n
</code></pre><ul>
<li>
<p><strong>提取所有 11 位数字电话号码</strong></p>
<pre><code>\d{11}
</code></pre><p>匹配结果</p>
<pre><code>17664999502
17187690316
14210007607
15878807133
15575237523
15695435545
18346347153
17017338288
15481361668
13528947724
18522824481
14352788577
18637851730
15862244782
14363718204
13418111578
15657258884
17574922377
14517362847
18088271014
17897166967
</code></pre></li>
<li>
<p><strong>提取所有 18 或 13 开头的电话号码</strong></p>
<pre><code>(18|13)\d{9}
</code></pre><p>匹配结果</p>
<pre><code>18346347153
13528947724
18522824481
18637851730
13418111578
18088271014
</code></pre></li>
<li>
<p><strong>提取所有“王”姓同学的名字</strong></p>
<pre><code>王\S*
</code></pre><p>匹配结果</p>
<pre><code>王伟
王芳
王秀英
王静
王丽
王敏
王磊
</code></pre></li>
<li>
<p><strong>提取所有“张”姓同学的电话号码</strong></p>
<pre><code>(张\S*) *(\d{11})    ||    $1 的电话是 $2
</code></pre><p>匹配结果</p>
<pre><code>张伟 的电话是 17664999502
张秀英 的电话是 17017338288
张敏 的电话是 13528947724
张丽 的电话是 14352788577
张静 的电话是 13418111578
</code></pre></li>
<li>
<p><strong>重新排版</strong></p>
<pre><code>(\S*) *(\d{11})    ||    $1 - $2
</code></pre><p><strong>匹配结果</strong></p>
<pre><code>张伟 - 17664999502
王伟 - 17187690316
王芳 - 14210007607
李伟 - 15878807133
王秀英 - 15575237523
李秀英 - 15695435545
李娜 - 18346347153
张秀英 - 17017338288
刘伟 - 15481361668
张敏 - 13528947724
李静 - 18522824481
张丽 - 14352788577
王静 - 18637851730
王丽 - 15862244782
李强 - 14363718204
张静 - 13418111578
李敏 - 15657258884
王敏 - 17574922377
王磊 - 14517362847
李军 - 18088271014
刘洋 - 17897166967
</code></pre></li>
</ul>
<h3 id="高效文本处理---2">高效文本处理 - 2</h3>
<p>原始文本如下</p>
<pre><code># 日期格式混乱的姓名簿

   张伟         1999年11月16日  王伟      1994.11.14    
 王芳   1991年12月15日       李伟     1993-3-16       王秀英   1993年11月7日   
  李秀英      1992-1-18  
   李娜  1996年9月6日     张秀英       1995-6-0       刘伟         1996年1月4日    张敏       1995.3.16    
  李静       1996-6-27        张丽 1997-6-28     
  王静  1997-5-4    
   王丽       1996-1-2 
  李强      1991-4-21  
 张静      1991-9-7       李敏   1997-6-5   
   王敏    1999年2月9日  
   王磊         1997-8-19      李军        1990年6月4日    
    刘洋      1999-6-25   
</code></pre><ul>
<li><strong>提取所有日期</strong>
<pre><code>\d{4}\S\d{1,2}\S\d{1,2}\S?
</code></pre><p>匹配结果</p>
<pre><code>1999年11月16日
1994.11.14
1991年12月15日
1993-3-16
1993年11月7日
1992-1-18
1996年9月6日
1995-6-0
1996年1月4日
1995.3.16
1996-6-27
1997-6-28
1997-5-4
1996-1-2
1991-4-21
1991-9-7
1997-6-5
1999年2月9日
1997-8-19
1990年6月4日
1999-6-25
</code></pre></li>
<li><strong>提取所有 1996 年以前出生的学生</strong>
<pre><code>(\S*) *199[0-5]\S\d{1,2}\S\d{1,2}\S?
</code></pre><p>匹配结果</p>
<pre><code>王伟      1994.11.14
王芳   1991年12月15日
李伟     1993-3-16
王秀英   1993年11月7日
李秀英      1992-1-18
张秀英       1995-6-0
张敏       1995.3.16
李强      1991-4-21
张静      1991-9-7
李军        1990年6月4日
</code></pre></li>
<li><strong>重新排版</strong>
<pre><code>(\S*) *(\d{4})\S(\d{1,2})\S(\d{1,2})\S?  ||  $1： $2 年 $3 月 $4 日
</code></pre><p>匹配结果</p>
<pre><code>张伟： 1999 年 11 月 16 日
王伟： 1994 年 11 月 14 日
王芳： 1991 年 12 月 15 日
李伟： 1993 年 3 月 16 日
王秀英： 1993 年 11 月 7 日
李秀英： 1992 年 1 月 18 日
李娜： 1996 年 9 月 6 日
张秀英： 1995 年 6 月 0 日
刘伟： 1996 年 1 月 4 日
张敏： 1995 年 3 月 16 日
李静： 1996 年 6 月 27 日
张丽： 1997 年 6 月 28 日
王静： 1997 年 5 月 4 日
王丽： 1996 年 1 月 2 日
李强： 1991 年 4 月 21 日
张静： 1991 年 9 月 7 日
李敏： 1997 年 6 月 5 日
王敏： 1999 年 2 月 9 日
王磊： 1997 年 8 月 19 日
李军： 1990 年 6 月 4 日
刘洋： 1999 年 6 月 25 日
</code></pre></li>
<li><strong>把所有 1996 年以前出生的学生出生年份改为 1996</strong>
<pre><code>(\S*) *(199[0-5])\S(\d{1,2})\S(\d{1,2})\S?    ||    $1： 1996 年 $3 月 $4 日
</code></pre><p>匹配结果</p>
<pre><code>王伟： 1996 年 11 月 14 日
王芳： 1996 年 12 月 15 日
李伟： 1996 年 3 月 16 日
王秀英： 1996 年 11 月 7 日
李秀英： 1996 年 1 月 18 日
张秀英： 1996 年 6 月 0 日
张敏： 1996 年 3 月 16 日
李强： 1996 年 4 月 21 日
张静： 1996 年 9 月 7 日
李军： 1996 年 6 月 4 日
</code></pre></li>
<li><strong>提取生日</strong>
<pre><code>(\S*) *(199[0-5])\S(\d{1,2})\S(\d{1,2})\S?    ||    $1的生日是$3月$4号
</code></pre><p>匹配结果</p>
<pre><code>张伟的生日是11月16号
王伟的生日是11月14号
王芳的生日是12月15号
李伟的生日是3月16号
王秀英的生日是11月7号
李秀英的生日是1月18号
李娜的生日是9月6号
张秀英的生日是6月0号
刘伟的生日是1月4号
张敏的生日是3月16号
李静的生日是6月27号
张丽的生日是6月28号
王静的生日是5月4号
王丽的生日是1月2号
李强的生日是4月21号
张静的生日是9月7号
李敏的生日是6月5号
王敏的生日是2月9号
王磊的生日是8月19号
李军的生日是6月4号
刘洋的生日是6月25号
</code></pre></li>
</ul>
<h3 id="代码重构">代码重构</h3>
<p>原始文本如下</p>
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class="k">def</span> <span class="nf">fib</span><span class="p">():</span>
    <span class="k">return</span> <span class="p">((</span><span class="mi">1</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span><span class="o">**</span><span class="n">n</span><span class="o">-</span><span class="p">(</span><span class="mi">1</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span><span class="o">**</span><span class="n">n</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="mi">2</span><span class="o">**</span><span class="n">n</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span>

<span class="k">def</span> <span class="nf">subfib</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">):</span>
    <span class="k">for</span> <span class="n">cur</span> <span class="ow">in</span> <span class="n">fib</span><span class="p">():</span>
        <span class="k">if</span> <span class="n">cur</span> <span class="o">&gt;</span> <span class="n">end</span><span class="p">:</span> <span class="k">return</span>
        <span class="k">if</span> <span class="n">cur</span> <span class="o">&gt;=</span> <span class="n">start</span><span class="p">:</span>
            <span class="k">print</span> <span class="n">cur</span>
            <span class="k">yield</span> <span class="n">cur</span>

<span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
   <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span>

<span class="k">print</span> <span class="s1">&#39;fibonacci 10~100:&#39;</span>
<span class="k">print</span> <span class="n">subfib</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
</code></pre></div><ul>
<li><strong>调整缩进，将四空格缩进重构为八个空格</strong>
<pre><code>^(\s+)    ||    $1$1
</code></pre><p>处理结果如下</p>
<pre><code>def fib():
        return ((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))

def subfib(start, end):
        for cur in fib():
                if cur &gt; end: return
                if cur &gt;= start:
                        print cur
                        yield cur

def foo(a, b):
      return a + b

print 'fibonacci 10~100:'
print subfib(10, 100)
</code></pre></li>
<li><strong>重构 Python2 的 print 语法为 Python3 的 print() 函数</strong>
<pre><code>print *(.*)$    ||    print($1)
</code></pre><p>处理结果如下</p>
<pre><code>def fib():
    return ((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))

def subfib(start, end):
    for cur in fib():
        if cur &gt; end: return
        if cur &gt;= start:
            print(cur)
            yield cur

def foo(a, b):
   return a + b

print('fibonacci 10~100:')
print(subfib(10, 100))
</code></pre></li>
<li>**所有函数声明添加 func_ 前缀**
<pre><code>def *(.*)    ||    def func_$1
</code></pre><p>处理结果如下</p>
<pre><code>def func_fib():
    return ((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))

def func_subfib(start, end):
    for cur in fib():
        if cur &gt; end: return
        if cur &gt;= start:
            print cur
            yield cur

def func_foo(a, b):
   return a + b

print 'fibonacci 10~100:'
print subfib(10, 100)
</code></pre></li>
<li><strong>交换函数声明中的参数位置</strong>
<pre><code>def (.*?)\((\w+), *(\w+)\)    ||    def $1($3, $2)
</code></pre><p>处理结果如下</p>
<pre><code>def fib():
    return ((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))

def subfib(end, start):
    for cur in fib():
        if cur &gt; end: return
        if cur &gt;= start:
            print cur
            yield cur

def foo(b, a):
   return a + b

print 'fibonacci 10~100:'
print subfib(10, 100)
</code></pre></li>
<li><strong>为所有函数添加注释模板</strong>
<pre><code>def *(.*):    ||    def $1:   &quot;&quot;&quot;    函数描述:    参数:    返回值:  &quot;&quot;&quot;
</code></pre><p>处理结果如下</p>
<pre><code>def fib():
   &quot;&quot;&quot;
    函数描述:
    参数:
    返回值:
  &quot;&quot;&quot;
    return ((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))

def subfib(start, end):
   &quot;&quot;&quot;
    函数描述:
    参数:
    返回值:
  &quot;&quot;&quot;
    for cur in fib():
        if cur &gt; end: return
        if cur &gt;= start:
            print cur
            yield cur

def foo(a, b):
   &quot;&quot;&quot;
    函数描述:
    参数:
    返回值:
  &quot;&quot;&quot;
   return a + b

print 'fibonacci 10~100:'
print subfib(10, 100)
</code></pre></li>
</ul>
<h3 id="数据格式验证">数据格式验证</h3>
<p>数据格式验证是正则表达式的一个常用领域，网站通常使用正则表达式来判断用户提交的信息是否符合规范。
下面的正则表达式都相当复杂，幸运的是你不需要记忆这些常用的正则表达式，需要时通过任何搜索引擎都能够找到。</p>
<ul>
<li><strong>邮箱验证</strong>
原始文本
<pre><code>123@qq.com
asdf@gmail.com
surname@blah.com
name.name@123.com
1242135.com
@foo.com
a@a
name @bla.com
</code></pre><p>正则表达式</p>
<pre><code>^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$
</code></pre><p>处理结果</p>
<pre><code>123@qq.com
asdf@gmail.com
surname@blah.com
name.name@123.com
</code></pre></li>
<li><strong>密码强度验证（最少八个字符，至少一个大写字母，一个小写字母和一个数字）</strong>
原始文本
<pre><code>123456
wdfqe#wefDdf123
wjleif932
8Ij12340
password
11111111ABc
hello
qweasdzxc
</code></pre><p>正则表达式</p>
<pre><code>^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^\n]{8,}$
</code></pre><p>处理结果</p>
<pre><code>wdfqe#wefDdf123
8Ij12340
11111111ABc
</code></pre></li>
<li><strong>18 位身份证号验证</strong>
原始文本
<pre><code>23010519491231002X
33010517491231232X
67810519491331214X
22010519491232452X
123412195292349132
123412196712234932
a23rr23451235t123f
124123580913457102
</code></pre><p>正则表达式</p>
<pre><code>^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$
</code></pre><p>处理结果</p>
<pre><code>23010519491231002X
123412196712234932
</code></pre></li>
<li><strong>IP 地址验证</strong>
原始文本
<pre><code>1.0.0.0
12.3.4.5
192.168.1.1
192.168.256.1
1.2.2.2
0.0.0.0
2.3.4
-1.2.3.4
</code></pre><p>正则表达式</p>
<pre><code>^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
</code></pre><p>处理结果</p>
<pre><code>1.0.0.0
12.3.4.5
192.168.1.1
1.2.2.2
0.0.0.0
</code></pre></li>
<li><strong>手机号验证</strong>
原始文本
<pre><code>12345678900
12354125235
15423423523
15123458654
8613890235892
017728384893
11111111111
</code></pre><p>正则表达式</p>
<pre><code>^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$
</code></pre><p>处理结果</p>
<pre><code>15123458654
8613890235892
017728384893
</code></pre></li>
</ul>
<h3 id="网络爬虫">网络爬虫</h3>
<p>网络爬虫提取数据也离不开正则表达式。</p>
<ul>
<li><strong>提取所有 HTML 标签</strong>
正则表达式
<pre><code>&lt;(&quot;[^&quot;]*&quot;|'[^']*'|[^'&quot;&gt;])*&gt;
</code></pre><p>原始文本</p>
<div class="highlight"><pre class="chroma"><code class="language-html" data-lang="html"><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hotnews&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;imgview&#34;</span> <span class="na">id</span><span class="o">=</span><span class="s">&#34;imgView&#34;</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span><span class="p">&gt;&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;&lt;</span><span class="nt">ul</span><span class="p">&gt;&lt;</span><span class="nt">li</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hdline0&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;a3&#34;</span><span class="p">&gt;</span>
习近平的改革之“喻” <span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">li</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hdline1&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span><span class="p">&gt;</span>
《必由之路》宣传片<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">i</span> <span class="na">style</span><span class="o">=</span><span class="s">&#34;font-size: 12px&#34;</span><span class="p">&gt;</span><span class="ni">&amp;nbsp;</span><span class="p">&lt;/</span><span class="nt">i</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://politics.gmw.cn/2018-12/11/content_32146726.htm&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span><span class="p">&gt;</span>
主题歌《梦想阳光》发布 <span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">li</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hdline2&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg&#34;</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;a3&#34;</span><span class="p">&gt;</span>
【央视快评】坚持中国特色人权发展道路<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">li</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hdline3&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span><span class="p">&gt;</span>同舟共济<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">i</span> <span class="na">style</span><span class="o">=</span><span class="s">&#34;font-size: 12px&#34;</span><span class="p">&gt;</span><span class="ni">&amp;nbsp;</span><span class="p">&lt;/</span><span class="nt">i</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span><span class="p">&gt;</span>
《改革开放 关键一招》第一集<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">li</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hdline4&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;a3&#34;</span><span class="p">&gt;</span>
【数说改革开放40年】40年减贫7.4亿人<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">li</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;hdline5&#34;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news&#34;</span> <span class="na">target</span><span class="o">=</span><span class="s">&#34;_blank&#34;</span><span class="p">&gt;</span>王岐山出席的这个活动，有什么来头？<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</code></pre></div><p>处理结果</p>
<pre><code>&lt;div class=&quot;hotnews&quot;&gt;
&lt;div class=&quot;imgview&quot; id=&quot;imgView&quot;&gt;
&lt;a href=&quot;https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com&quot; target=&quot;_blank&quot;&gt;
&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg&quot;&gt;
&lt;/a&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;hdline0&quot;&gt;
&lt;a href=&quot;http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline1&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html&quot; target=&quot;_blank&quot;&gt;
&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;
&lt;/i&gt;
&lt;a href=&quot;http://politics.gmw.cn/2018-12/11/content_32146726.htm&quot; target=&quot;_blank&quot;&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline2&quot;&gt;
&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg&quot;&gt;
&lt;a href=&quot;http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline3&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html&quot; target=&quot;_blank&quot;&gt;
&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;
&lt;/i&gt;
&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml&quot; target=&quot;_blank&quot;&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline4&quot;&gt;
&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline5&quot;&gt;
&lt;a href=&quot;http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news&quot; target=&quot;_blank&quot;&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</code></pre></li>
<li><strong>清洗所有 HTML 标签</strong>
正则表达式
<pre><code>&lt;(&quot;[^&quot;]*&quot;|'[^']*'|[^'&quot;&gt;])*&gt;    ||    ' '
</code></pre><p>原始文本</p>
<pre><code>&lt;div class=&quot;hotnews&quot;&gt;
&lt;div class=&quot;imgview&quot; id=&quot;imgView&quot;&gt;&lt;a href=&quot;https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li class=&quot;hdline0&quot;&gt;
&lt;a href=&quot;http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
习近平的改革之“喻” &lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline1&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html&quot; target=&quot;_blank&quot;&gt;
《必由之路》宣传片&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://politics.gmw.cn/2018-12/11/content_32146726.htm&quot; target=&quot;_blank&quot;&gt;
主题歌《梦想阳光》发布 &lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline2&quot;&gt;
&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg&quot;&gt;&lt;a href=&quot;http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【央视快评】坚持中国特色人权发展道路&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline3&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html&quot; target=&quot;_blank&quot;&gt;同舟共济&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml&quot; target=&quot;_blank&quot;&gt;
《改革开放 关键一招》第一集&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline4&quot;&gt;
&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【数说改革开放40年】40年减贫7.4亿人&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline5&quot;&gt;
&lt;a href=&quot;http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news&quot; target=&quot;_blank&quot;&gt;王岐山出席的这个活动，有什么来头？&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</code></pre><p>处理结果</p>
<pre><code>  
习近平的改革之“喻”   
  
《必由之路》宣传片 
 &amp;nbsp;  
主题歌《梦想阳光》发布  
  
【央视快评】坚持中国特色人权发展道路  
   
 同舟共济 
 &amp;nbsp;  
《改革开放 关键一招》第一集 
  
【数说改革开放40年】40年减贫7.4亿人  
 王岐山出席的这个活动，有什么来头？ 
</code></pre></li>
<li><strong>提取所有 URL</strong>
正则表达式
<pre><code>(https?|ftp|file)(:/)?/[-A-Za-z0-9+&amp;@#/%?=~_|!:,.;]+[-A-Za-z0-9+&amp;@#/%=~_|]
</code></pre><p>原始文本</p>
<pre><code>&lt;div class=&quot;hotnews&quot;&gt;
&lt;div class=&quot;imgview&quot; id=&quot;imgView&quot;&gt;&lt;a href=&quot;https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li class=&quot;hdline0&quot;&gt;
&lt;a href=&quot;http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
习近平的改革之“喻” &lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline1&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html&quot; target=&quot;_blank&quot;&gt;
《必由之路》宣传片&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://politics.gmw.cn/2018-12/11/content_32146726.htm&quot; target=&quot;_blank&quot;&gt;
主题歌《梦想阳光》发布 &lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline2&quot;&gt;
&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg&quot;&gt;&lt;a href=&quot;http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【央视快评】坚持中国特色人权发展道路&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline3&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html&quot; target=&quot;_blank&quot;&gt;同舟共济&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml&quot; target=&quot;_blank&quot;&gt;
《改革开放 关键一招》第一集&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline4&quot;&gt;
&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【数说改革开放40年】40年减贫7.4亿人&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline5&quot;&gt;
&lt;a href=&quot;http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news&quot; target=&quot;_blank&quot;&gt;王岐山出席的这个活动，有什么来头？&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</code></pre><p>处理结果</p>
<pre><code>https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com
https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg
http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm
http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html
http://politics.gmw.cn/2018-12/11/content_32146726.htm
https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg
http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html
http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html
http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml
http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml
http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news
</code></pre></li>
<li><strong>提取所有 JPG 图片的 URL</strong>
正则表达式
<pre><code>(https?|ftp|file)(:/)?/[-A-Za-z0-9+&amp;@#/%?=~_|!:,.;]+[-A-Za-z0-9+&amp;@#/%=~_|].jpg
</code></pre><p>原始文本</p>
<pre><code>&lt;div class=&quot;hotnews&quot;&gt;
&lt;div class=&quot;imgview&quot; id=&quot;imgView&quot;&gt;&lt;a href=&quot;https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li class=&quot;hdline0&quot;&gt;
&lt;a href=&quot;http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
习近平的改革之“喻” &lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline1&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html&quot; target=&quot;_blank&quot;&gt;
《必由之路》宣传片&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://politics.gmw.cn/2018-12/11/content_32146726.htm&quot; target=&quot;_blank&quot;&gt;
主题歌《梦想阳光》发布 &lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline2&quot;&gt;
&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg&quot;&gt;&lt;a href=&quot;http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【央视快评】坚持中国特色人权发展道路&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline3&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html&quot; target=&quot;_blank&quot;&gt;同舟共济&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml&quot; target=&quot;_blank&quot;&gt;
《改革开放 关键一招》第一集&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline4&quot;&gt;
&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【数说改革开放40年】40年减贫7.4亿人&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline5&quot;&gt;
&lt;a href=&quot;http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news&quot; target=&quot;_blank&quot;&gt;王岐山出席的这个活动，有什么来头？&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</code></pre><p>处理结果</p>
<pre><code>https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg
</code></pre></li>
</ul>
<p><a href="https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg">https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg</a>
```</p>
<ul>
<li><strong>提取所有中文和中文标点</strong>
正则表达式
<pre><code>[\u4e00-\u9fa5\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]+
</code></pre><p>原始文本</p>
<pre><code>&lt;div class=&quot;hotnews&quot;&gt;
&lt;div class=&quot;imgview&quot; id=&quot;imgView&quot;&gt;&lt;a href=&quot;https://xinwen.eastday.com/a/n181211075002407.html?qid=news.baidu.com&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=cdae0fb78a94a4c20c23e32b3ef51bac/cefc1e178a82b90151b62d8b7e8da9773912ef6b.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li class=&quot;hdline0&quot;&gt;
&lt;a href=&quot;http://www.xinhuanet.com/politics/xxjxs/2018-12/11/c_1123834898.htm&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
习近平的改革之“喻” &lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline1&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181211/313376c7-77cc-abff-3a81-bd855c0a8577.html&quot; target=&quot;_blank&quot;&gt;
《必由之路》宣传片&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://politics.gmw.cn/2018-12/11/content_32146726.htm&quot; target=&quot;_blank&quot;&gt;
主题歌《梦想阳光》发布 &lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline2&quot;&gt;
&lt;img src=&quot;https://imgsa.baidu.com/news/q%3D100/sign=ab45ee53bbfd5266a12b38149b199799/f9198618367adab46063f9fb86d4b31c8601e4d3.jpg&quot;&gt;&lt;a href=&quot;http://politics.people.com.cn/n1/2018/1211/c1001-30458946.html&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【央视快评】坚持中国特色人权发展道路&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline3&quot;&gt;
&lt;a href=&quot;http://news.cri.cn/20181210/384ab948-e36b-b455-9d97-8eb05172c179.html&quot; target=&quot;_blank&quot;&gt;同舟共济&lt;/a&gt;
&lt;i style=&quot;font-size: 12px&quot;&gt;&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTI9v2GwcDNkh8obJh2vnUy181210.shtml&quot; target=&quot;_blank&quot;&gt;
《改革开放 关键一招》第一集&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;hdline4&quot;&gt;
&lt;a href=&quot;http://news.cctv.com/2018/12/10/ARTISzd4ekNLNB88EFFtMgB7181210.shtml&quot; target=&quot;_blank&quot; class=&quot;a3&quot;&gt;
【数说改革开放40年】40年减贫7.4亿人&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;hdline5&quot;&gt;
&lt;a href=&quot;http://news.ifeng.com/a/20181211/60188943_0.shtml?_zbs_baidu_news&quot; target=&quot;_blank&quot;&gt;王岐山出席的这个活动，有什么来头？&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</code></pre><p>处理结果</p>
<pre><code>习近平的改革之“喻”
《必由之路》宣传片
主题歌《梦想阳光》发布
央视快评
坚持中国特色人权发展道路
同舟共济
《改革开放
关键一招》第一集
数说改革开放
年
年减贫
亿人
王岐山出席的这个活动，有什么来头？
</code></pre></li>
</ul>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/">正则表达式</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-02/docker%E6%97%A5%E5%BF%97%E5%A4%AA%E5%A4%9A%E5%AF%BC%E8%87%B4%E7%A3%81%E7%9B%98%E5%8D%A0%E6%BB%A1/">
                <h2 class="post-title">Docker日志太多导致磁盘占满</h2>

                
              </a>

              <p class="post-meta">
                Posted on February 25, 2019
              </p>
              <div class="post-entry">
                
                  <h2 id="docker日志太多导致磁盘占满">Docker日志太多导致磁盘占满</h2>
<p>我有一台服务器上面部署了多个docker容器， 并且每个docker容器都往stderr中源源不断的输出日志，导致今天磁盘被占满了。搜索了一下，docker官方网站上提供了一篇解决方案的<a href="https://success.docker.com/article/no-space-left-on-device-error">文章</a>。</p>
<p>Docker容器在启动/重启的时候会往/var/lib/docker中写东西，如果你在启动docker容器遇到No space left on device的问题，可以按照下面的步骤进行清理相关的日志操作。</p>
<ol>
<li><strong>对 <code>/var/lib/docker/containers</code> 下的文件夹进行排序，看看哪个容器占用了太多的磁盘空间</strong></li>
</ol>
<pre><code># 命令会按照升序的方式对于容器文件夹进行排序，并列出容器文件夹的大小
du -d1 -h /var/lib/docker/containers | sort -h


[root@dbl14195 testnet]# du -d1 -h /var/lib/docker/containers | sort -h
36K	/var/lib/docker/containers/4d91f92dd7604216f2e9e123572e9a80d7bbee3d8c8ce7be2ed241c572816fb6
40K	/var/lib/docker/containers/374aa0ba92b37d829012282ff15c1bb838d95dedb54589874c4285991be2d4aa
40K	/var/lib/docker/containers/7cfdbc453b2f7109b52e974061754266e6cdc0ccaee62ab4a5887865113e1144
40K	/var/lib/docker/containers/84ee24989ad52383c6e99eaa4d236e600095aa7f855e81fbafe10416b75ceefb
40K	/var/lib/docker/containers/aeced3ef3e23df27e52f65743bb05448b46a2c660acc5b0aab12604e060779b4
40K	/var/lib/docker/containers/c36722baf0d2e1c22b7dde9979665ab62cd8ab85c3f1d0f427bb7a34e0fd977a
44K	/var/lib/docker/containers/62477b332d18e192d70c7420435d47a379e6bbd8de13da8a8762e0fd95b341ca
44K	/var/lib/docker/containers/78da0cf9743b6940fabbbd8c574b99dc5deb642fa998a8f819a6c6978fc875d7
44K	/var/lib/docker/containers/9f63daf7caa7c469385bed4b178fbfe662e15b8c569c6644081af090f8e40426
44K	/var/lib/docker/containers/e2d1286119a45aac7e58d6dac6e4b44b1d1288799b735943be45abed50244e56
56K	/var/lib/docker/containers/ebd1bd211a1b9d02bb39bfb80eec3d0960a5b25e18f54d7371781ec456e7a1e8
176K	/var/lib/docker/containers/1fe0a241e5ce9726c547c68739793633f9dd906768a36fe80e8fb80373aa3bfb
17M	/var/lib/docker/containers/ac30e68d454b37d22b3964053a2b52ba043baa1add13556a09c0e3e05589104f
25M	/var/lib/docker/containers/872ca4e3d005594591ca2df0e832d36eef448981ab2820c69df4ff1399f8423e
25M	/var/lib/docker/containers/bd49a0a0368b99a9f69981d8b921ea1830957451577b635a07d5425d48e1144b
30M	/var/lib/docker/containers/8f732390a020a6ef647fabb04da32c87d6341b72ac2af6bb4a1cf5743fda54db
88M	/var/lib/docker/containers/648e883aa0a93f696f64e4ab76434657f4845769fe1eaaad49c2dc1d7960f2b0
171M	/var/lib/docker/containers/8de7ff9f0276586a6ab346c2be1c9dc879bbb0d795fa7776c1d8d1568ea2794a
354M	/var/lib/docker/containers
</code></pre><ol start="2">
<li><strong>选择你要清理的容器进行清理</strong></li>
</ol>
<pre><code>$ cat /dev/null &gt; /var/lib/docker/containers/container_id/container_log_name
</code></pre><pre><code>上述命令会清空对应的日志,如:
</code></pre>
<pre><code>cat /dev/null &gt; /var/lib/docker/containers/374aa0ba92b37d829012282ff15c1bb838d95dedb54589874c4285991be2d4aa/374aa0ba92b37d829012282ff15c1bb838d95dedb54589874c4285991be2d4aa-json.log
</code></pre><ol start="3">
<li><strong>限制日志文件的大小</strong>
启动容器时，可以通过参数设置日志文件的大小、日志文件的<a href="https://docs.docker.com/config/containers/logging/json-file/#options">格式</a>。</li>
</ol>
<pre><code>docker run -it --log-opt max-size=10m --log-opt max-file=3 alpine ash
</code></pre>
                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/docker/">Docker</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E6%97%A5%E5%BF%97/">日志</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E6%B8%85%E7%90%86/">清理</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-02/docker-system-%E4%B8%80%E4%B8%AA%E5%85%A8%E6%96%B0%E7%9A%84%E5%91%BD%E4%BB%A4%E9%9B%86%E5%90%88/">
                <h2 class="post-title">docker system —— 一个全新的命令集合</h2>

                
              </a>

              <p class="post-meta">
                Posted on February 20, 2019
              </p>
              <div class="post-entry">
                
                  <p>docker system 目前拥有四个子命令,分别是：</p>
<pre><code>docker system df
docker system events
docker system info
docker system prune
</code></pre><p>docker system 其中最重要的一个命令就是 <code>docker system prune</code> 命令，清理没有使用的数据，包括镜像数据，已经停止的容器</p>
<h2 id="查看-docker-system-帮助">查看 docker system 帮助</h2>
<pre><code>[root@localhost ~]# docker system --help

Usage:  docker system COMMAND

Manage Docker

Options:
      --help   Print usage

Commands:
  df          Show docker disk usage
  events      Get real time events from the server
  info        Display system-wide information
  prune       Remove unused data

Run 'docker system COMMAND --help' for more information on a command.
[root@localhost ~]# 
</code></pre><h2 id="docker-system-df">docker system df</h2>
<p>提供Docker整体磁盘使用率的概况，包括镜像、容器和（本地）volume。所以我们现在随时都可以查看Docker使用了多少资源。</p>
<pre><code>[root@localhost ~]# docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              10                  6                   2.652GB             1.953GB (73%)
Containers          6                   6                   6.922MB             0B (0%)
Local Volumes       0                   0                   0B                  0B
[root@localhost ~]# 
</code></pre><h2 id="docker-system-prune">docker system prune</h2>
<p>如果之前的命令展示出 docker 已经占用了太多空间，我们会开始清理。有一个包办一切的命令：</p>
<pre><code>[root@localhost ~]# docker system prune
WARNING! This will remove:
        - all stopped containers # 清理停止的容器
        - all networks not used by at least one container #清理没有使用的网络
        - all dangling images #清理废弃的镜像
        - all build cache #清理构建缓存
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B
[root@localhost ~]# 
</code></pre><p>根据警告信息可知，这个命令会删除所有关闭的容器以及dangling镜像。示例中，含有3个1GB随机文件的镜像的名称被占用了，名称为:，为dangling镜像，因此会被删除。同时，所有的中间镜像也会被删除。</p>
<p>更进一步，使用-a选项可以做深度清理。这时我们会看到更加严重的WARNING信息:</p>
<pre><code>$ docker system prune -a
WARNING! This will remove:
        - all stopped containers
        - all volumes not used by at least one container
        - all networks not used by at least one container
        - all images without at least one container associated to them
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: test:latest
deleted: sha256:c515ebfa2...
deleted: sha256:07302c011...
deleted: sha256:37c0c6474...
deleted: sha256:5cc2b6bc4...
deleted: sha256:b283b9c35...
deleted: sha256:8a8b9bd8b...
untagged: alpine:latest
untagged: alpine@sha256:58e1a1bb75db1...
deleted: sha256:4a415e366...
deleted: sha256:23b9c7b43...
Total reclaimed space: 2.151GB
</code></pre><p>这个命令将清理整个系统，并且只会保留真正在使用的镜像，容器，数据卷以及网络，因此需要格外谨慎。比如，我们不能在生产环境中运行prune -a命令，因为一些备用镜像(用于备份，回滚等)有时候需要用到，如果这些镜像被删除了，则运行容器时需要重新下载。</p>
<p>此时，所有未绑定容器的镜像将会被删除。由于第一次prune命令删除了所有容器，因此所有镜像(它们没有绑定任何容器)都会被删除。</p>
<h2 id="docker-systemc-info-docker-info">docker systemc info （docker info）</h2>
<p>这个命令的缩写<code>docker info</code>相信大家都很熟悉</p>
<pre><code>[root@localhost ~]# docker system info
Containers: 6
 Running: 6
 Paused: 0
 Stopped: 0
Images: 49
Server Version: 17.06.2-ce
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.26.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 31.21GiB
Name: localhost.localdomain
ID: YTL2:6RWX:IZK6:X4XC:XKMO:WVXD:LXPR:E5GN:GEJB:WIUX:L5YH:PDFB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 http://9zkjjecg.mirror.aliyuncs.com/
 https://docker.mirrors.ustc.edu.cn/
Live Restore Enabled: false

[root@localhost ~]# 
</code></pre><h2 id="详细的解释">详细的解释</h2>
<table>
<thead>
<tr>
<th align="left">元字符</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">info<!-- raw HTML omitted -->等同于 docker info</td>
<td>查看整个docker系统的信息<!-- raw HTML omitted --> 例如 docker system info<!-- raw HTML omitted -->例如 docker system info | grep Images</td>
</tr>
<tr>
<td align="left">events<!-- raw HTML omitted -->等同于 docker events</td>
<td>获取docker系统实时事件，不包括容器内的。<!-- raw HTML omitted -->例如：docker system events –until 1499305500<!-- raw HTML omitted -->        // 截止到 2017.7.6 01:45:00的操作<!-- raw HTML omitted -->例如：docker system events –since 1499305500<!-- raw HTML omitted -->        // 从 2017.7.6 01:45:00之后的操作</td>
</tr>
<tr>
<td align="left">df</td>
<td>整体磁盘的使用情况<!-- raw HTML omitted -->例如：docker system df<!-- raw HTML omitted -->例如：docker system df -v</td>
</tr>
<tr>
<td align="left">prune</td>
<td>清理资源，**此操作尤其需要注意。**<!-- raw HTML omitted -->例如：docker system prune <!-- raw HTML omitted -->#包括清理以下的四种，即容器、镜像、数据卷、网络<!-- raw HTML omitted -->– all stopped containers<!-- raw HTML omitted -->– all volumes not used by at least one container<!-- raw HTML omitted -->– all networks not used by at least one container<!-- raw HTML omitted -->– all dangling images<!-- raw HTML omitted --><!-- raw HTML omitted -->例如：docker system prune -a<!-- raw HTML omitted -->#包括以下的四种情况，主要和上比较<!-- raw HTML omitted -->– all stopped containers<!-- raw HTML omitted -->– all volumes not used by at least one container<!-- raw HTML omitted -->– all networks not used by at least one container<!-- raw HTML omitted -->– <strong>all images without at least one container associated to them</strong></td>
</tr>
</tbody>
</table>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/docker/">Docker</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/system/">system</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-02/docker%E6%93%8D%E4%BD%9C%E5%91%BD%E4%BB%A4%E5%81%9C%E6%AD%A2%E5%88%A0%E9%99%A4%E7%AF%87/">
                <h2 class="post-title">Docker操作命令——停止、删除篇</h2>

                
              </a>

              <p class="post-meta">
                Posted on February 20, 2019
              </p>
              <div class="post-entry">
                
                  <h2 id="停止删除命令">停止、删除命令</h2>
<h4 id="列出所有的容器-id">列出所有的容器 ID</h4>
<pre><code>docker ps -aq
</code></pre><h4 id="停止所有的容器">停止所有的容器</h4>
<pre><code>docker stop $(docker ps -aq)
</code></pre><h4 id="删除所有的容器">删除所有的容器</h4>
<pre><code>docker rm $(docker ps -aq)
</code></pre><h4 id="删除所有的镜像">删除所有的镜像</h4>
<pre><code>docker rmi $(docker images -q)
</code></pre><h4 id="复制文件">复制文件</h4>
<pre><code>docker cp mycontainer:/opt/file.txt /opt/local/
docker cp /opt/local/file.txt mycontainer:/opt/
</code></pre><h4 id="更新部分">更新部分</h4>
<p>现在的docker有了专门清理资源(container、image、网络)的命令。 docker 1.13 中增加了 <strong><code>docker system prune</code></strong> 的命令
针对container、image可以使用 <strong><code>docker container prune</code></strong>、<strong><code>docker image prune</code></strong>命令</p>
<pre><code># 删除所有不使用的镜像
docker image prune --force --all或docker image prune -f -a

# 删除所有停止的容器
docker container prune -f
</code></pre>
                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/docker/">Docker</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E6%93%8D%E4%BD%9C/">操作</a>&nbsp;
                  
                </span>
              

            </article>
          
        </div>
        
          <ul class="pager main-pager">
            
              <li class="previous">
                <a href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/6">&larr; Newer Posts</a>
              </li>
            
            
              <li class="next">
                <a href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/8">Older Posts &rarr;</a>
              </li>
            
          </ul>
        
      </div>
    <div align="center" class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        

<ul class="pagination">
    
    <li class="page-item">
        <a href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/" class="page-link" aria-label="First"><span aria-hidden="true">&laquo;&laquo;</span></a>
    </li>
    
    <li class="page-item">
    <a href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/6/" class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
    </li>
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/">1</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/2/">2</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/3/">3</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item disabled"><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/6/">6</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item active"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/7/">7</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/8/">8</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item disabled"><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/11/">11</a></li>
    
    
    <li class="page-item">
    <a href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/8/" class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
    </li>
    
    <li class="page-item">
        <a href="https://systemime.github.io/series/%E6%9D%82%E6%8A%80%E6%B5%85%E5%B0%9D/page/11/" class="page-link" aria-label="Last"><span aria-hidden="true">&raquo;&raquo;</span></a>
    </li>
    
</ul>


        
        
        
        
        
      </div>
    </div>
  </div>

    <div class="rocket"><img src="https://systemime.github.io/img/rocket_up.png" alt="" width="100" height="100"></div>
<script>
    $(function () {
      $(window).scroll(function () {
        
        if ($(window).scrollTop() >= 1000) {
          $('.rocket').stop().fadeIn(1000);
        }else {
          $('.rocket').stop().fadeOut(1000);
        }
      })
      
      $('.rocket').click(function () {
        $('html,body').stop().animate({scrollTop:0},400);
       
      })
    })

</script>

    
    <div id="landlord">
        <div class="message" style="opacity:0"></div>
        <canvas id="live2d" width="280" height="250" class="live2d"></canvas>
        <div class="hide-button">隐藏</div>
    </div>
    
    <footer id="copyright">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <ul class="list-inline text-center footer-links">
          
          
        </ul>
        <p class="credits copyright text-muted">
        &copy;2017-2018
          
          &nbsp;&bull;&nbsp;
          September 20,2019
          updated
          
            &nbsp;&bull;&nbsp;
            <a href="https://systemime.github.io">Home</a>
          
        </p>

        <p class="credits theme-by text-muted">
        <a href="https://servicemesher.github.io" target="_blank">ServiceMesher</a>&nbsp;&bull;&nbsp;<a href="https://github.com/yangchuansheng/k8s-knowledge" target="_blank">Kubernetes 知识图谱</a>
        <br />
        <span id="busuanzi_container_site_pv">
            本站已被访问 <span id="busuanzi_value_site_pv"></span> 次啦
        </span>
        <span id="busuanzi_container_site_uv">
            &ensp;|&ensp;&thinsp;您是第 <span id="busuanzi_value_site_uv"></span> 位到访的小伙伴喔
        </span>
        </p>
        
        <p class="credits theme-by text-muted">
          <a href="http://gohugo.io">Hugo v0.67.0</a> powered &nbsp;&bull;&nbsp; Theme by <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a> adapted to <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a>
          
          <center><section class="credits theme-by text-muted">
    <span class="footer__copyright">
    <div>
    <span id="span_dt_dt"> </span>
    <script language="javascript">
      function show_date_time(){
        window.setTimeout("show_date_time()", 1000);
        BirthDay=new Date("7/8/2017 10:56:12");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=Math.floor(e_hrsold);
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=Math.floor((e_hrsold-hrsold)*60);
        seconds=Math.floor((e_minsold-minsold)*60);
        span_dt_dt.innerHTML="本博客已经开心运行 "+daysold+" 天 "+hrsold+" 小时 "+minsold+" 分 "+seconds+" 秒";
      }
      show_date_time();
    </script>
    </div>
</script>
</section>
</center>
        </p>
      </div>
    </div>
  </div>
</footer>


<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/bootstrap.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe-ui-default.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/auto-render.min.js"></script>
<script src="https://systemime.github.io/js/main.js"></script>
<script src="https://systemime.github.io/js/clipboard.min.js"></script>
<script src="https://systemime.github.io/js/prism.js?t=123"></script>
<script src="https://systemime.github.io/js/highlight.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/katex.min.js"></script>
<script src="https://systemime.github.io/js/reward.js"></script>
<script src="https://systemime.github.io/js/canvas_ribbon.js"></script>
<script> renderMathInElement(document.body); </script>

<script src="https://systemime.github.io/js/baguetteBox.js"></script>
<script> baguetteBox.run('.gallery');</script>






<script async defer src="https://buttons.github.io/buttons.js"></script>


<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
<script type="text/javascript" src="https://systemime.github.io/js/quicklink.umd.js"></script>
<script>
window.addEventListener('load', () =>{
   quicklink();
});
</script>



<script type="text/javascript">
 
var a_idx = 0;
jQuery(document).ready(function($) {
    $("body").click(function(e) {
        var a = new Array("Docker", "Kubernetes", "Prometheus", "Envoy", "Istio", "Service Mesh", "Cloud Native");
        var $i = $("<span />").text(a[a_idx]);
        a_idx = (a_idx + 1) % a.length;
        var x = e.pageX,
        y = e.pageY;
        function randomColor() {
          var flakeColor = new Array("#FFDA65", "#00BFFF", "#BA55D3", "#FFA07A", "#87CEEB", "#FFB6C1");
          var snowColor = flakeColor[Math.floor(flakeColor.length * Math.random())];
          return snowColor;
        }
        $i.css({
            "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": randomColor()
        });
        $("body").append($i);
        $i.animate({
            "top": y - 180,
            "opacity": 0
        },
        1500,
        function() {
            $i.remove();
        });
    });
});
</script>


<script type="text/javascript" src="https://systemime.github.io/js/lightbox.js"></script>











<script src="https://cdn.plyr.io/3.4.7/plyr.js"></script>
<script>const player = new Plyr('#player');</script>


<script async defer src="https://buttons.github.io/buttons.js"></script>


  </body>
</html>

